from django.conf.urls import url, include
from . import views
from rest_framework import routers

# 实例化路由器
router = routers.DefaultRouter()
# 绑定类视图， 但是
router.register(r'books', views.BookInfoViewset, base_name='book')

urlpatterns = [
    # url(r'books/$', views.BooksAPIView.as_view()),
    # url(r'books/(?P<id>\d+)$', views.BookAPIView.as_view())
    # url(r'book/(?P<pk>\d+)/$', views.BookDetailView2.as_view()),
    # url(r'books/$', views.BookDetailView.as_view()),
    # url(r'books_list/$', views.BookInfoViewset.as_view({'get':'list', 'post':'create'})),
    # url(r'books_list/(?P<pk>\d+)/$', views.BookInfoViewset.as_view({'get':'retrieve', 'put':'update', 'delete':'destroy'})),
    # url(r'books_list/latest/$', views.BookInfoViewset.as_view({'get': 'latest'})),
    url(r'^', include(router.urls))
]


# 添加url 到urlpatterns
# urlpatterns += router.urls